\r\n}","import React from 'react';\r\n\r\nexport interface IBlogPostProps {\r\n title: string;\r\n url: string;\r\n imgUrl: string;\r\n postSummery: string;\r\n publishDate: Date;\r\n isFavored: boolean;\r\n};\r\n\r\nexport const BlogPost = ({title, url, imgUrl, postSummery} : IBlogPostProps) => {\r\n return
\r\n
\r\n

\r\n
\r\n
{title}\r\n
{postSummery}
\r\n
\r\n\r\n};","import React, { useRef, useState, useEffect } from 'react';\r\nimport { render } from 'react-dom';\r\n\r\nimport { HeartLoader } from '../../../../../../prototype/src/components/HeartLoader';\r\nimport {IBlogPostProps, BlogPost} from '../../../../../../prototype/src/components/BlogPost'\r\n\r\ninterface IBlogPostBlockInfo {\r\n title: string,\r\n ctaUrl: string,\r\n ctaText: string,\r\n ctaUrlTarget: string,\r\n blogUrl: string,\r\n blogDivId: string,\r\n}\r\n\r\ndeclare global{\r\n interface Window {blogPostBlockInfo: IBlogPostBlockInfo}\r\n}\r\n\r\nconst options = {\r\n root: null,\r\n rootMargin: '0px',\r\n threshold: 0.001,\r\n};\r\n\r\nconst BlogPostsComponent = () => {\r\n\r\n const containerRef = useRef(null);\r\n const [isLoaded, setIsLoaded] = useState(false);\r\n const [blogPosts, setBlogPosts] = useState
([]);\r\n\r\n \r\n const getRSSData = () => {\r\n const requestOptions = {\r\n method: 'GET',\r\n headers: {\r\n 'User-Agent': 'ValleyMed.org Query',\r\n 'cache-control': 'no-cache',\r\n }\r\n };\r\n\r\n fetch(window.blogPostBlockInfo.blogUrl, requestOptions)\r\n .then((response) => response.text())\r\n .then((xmlText) => {\r\n const parser = new DOMParser();\r\n const xml = parser.parseFromString(xmlText.replace('\\n', '\\r\\n'), 'text/xml'); // replace \\n with \\r\\n otherwise you will get \"XML Parsing Error: not well-formed\" error\r\n var items = xml.querySelectorAll('item');\r\n var posts : IBlogPostProps[] = [];\r\n for (let i = 0; i < items.length; i++) {\r\n try { // skip any blog posts that cause problems.\r\n let item = items[i];\r\n if (item !== null){\r\n let title = item.querySelector('title')?.innerHTML;\r\n let desc = item.querySelector('description')?.innerHTML;\r\n let imgMatch = desc?.match(//i);\r\n var imgLink;\r\n if (imgMatch)\r\n imgLink = imgMatch[1];\r\n // Remove HTML tags and non-breaking spaces leaving a plain description.\r\n let subText = desc?.replace(/<[^>]+>| /g, ' ').trim();\r\n if (subText){\r\n // Truncate the description down to 60 characters or the length of the description, whichever is shorter.\r\n var subTextTrunLength = Math.min(subText.length, 60);\r\n subText = subText.substring(0, subTextTrunLength).concat('...');\r\n // make sure to convert html entities in the text back to readable text - such as ’ for apostraphe\r\n var subTextElem = document.createElement('p');\r\n subTextElem.innerHTML = subText;\r\n subText = subTextElem.textContent || subTextElem.innerText;\r\n\r\n }\r\n let isFavored = false;\r\n item.querySelectorAll('category').forEach(categoryElem => {if (isFavored) return; else if (categoryElem.innerHTML.includes('homepg')) isFavored = true});\r\n let publishDateElem = item.querySelector('pubDate');\r\n var publishDate;\r\n if (publishDateElem?.textContent)\r\n publishDate = new Date(publishDateElem?.textContent);\r\n var postLink = item.querySelector('link')?.innerHTML;\r\n if (postLink)\r\n posts.push({\r\n title: title || '', \r\n url: postLink, \r\n imgUrl: imgLink || '', \r\n postSummery: subText || '',\r\n isFavored: isFavored,\r\n publishDate: publishDate,\r\n });\r\n \r\n }\r\n }\r\n catch(ex) {\r\n console.log('blog post parse error', ex);\r\n }\r\n }\r\n // sort by wheather or not they are favored then sort by pubDate decending.\r\n let sortFunc = (a: IBlogPostProps, b: IBlogPostProps) => {\r\n if (a.isFavored == true && b.isFavored == false) \r\n return -1;\r\n else if (a.isFavored == false && b.isFavored == true)\r\n return 1;\r\n else if (a.publishDate > b.publishDate)\r\n return -1;\r\n else if (a.publishDate > b.publishDate)\r\n return 1;\r\n else\r\n return 0;\r\n\r\n \r\n }\r\n posts = posts.sort(sortFunc).slice(0,3);\r\n setBlogPosts(posts);\r\n });\r\n \r\n };\r\n \r\n const observeCallback = (entries, observer) => {\r\n entries.forEach(function (entry, index) {\r\n if (entry.isIntersecting && !isLoaded) {\r\n setIsLoaded(true);\r\n getRSSData();\r\n observer.disconnect();\r\n }\r\n })\r\n };\r\n\r\n useEffect(() => {\r\n if (containerRef.current){\r\n let observer = new IntersectionObserver(observeCallback, options);\r\n observer.observe(containerRef.current);\r\n }\r\n }, [containerRef, options]);\r\n \r\n return \r\n
\r\n
\r\n
{window.blogPostBlockInfo.title}
\r\n
\r\n { blogPosts.length > 0 ? (\r\n blogPosts.map(post => \r\n
\r\n ) \r\n ) : ( \r\n \r\n
Loading blog posts...
\r\n \r\n \r\n )\r\n }\r\n \r\n
{window.blogPostBlockInfo.ctaText}\r\n
\r\n
\r\n
\r\n \r\n};\r\n\r\n\r\nif (window.blogPostBlockInfo)\r\n render(, document.getElementById(window.blogPostBlockInfo.blogDivId));\r\n\r\n ","/*\nobject-assign\n(c) Sindre Sorhus\n@license MIT\n*/\n\n'use strict';\n/* eslint-disable no-unused-vars */\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nfunction toObject(val) {\n\tif (val === null || val === undefined) {\n\t\tthrow new TypeError('Object.assign cannot be called with null or undefined');\n\t}\n\n\treturn Object(val);\n}\n\nfunction shouldUseNative() {\n\ttry {\n\t\tif (!Object.assign) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Detect buggy property enumeration order in older V8 versions.\n\n\t\t// http://bugs.chromium.org/p/v8/issues/detail?id=4118\n\t\tvar test1 = new String('abc'); // eslint-disable-line no-new-wrappers\n\t\ttest1[5] = 'de';\n\t\tif (Object.getOwnPropertyNames(test1)[0] === '5') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// http://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test2 = {};\n\t\tfor (var i = 0; i < 10; i++) {\n\t\t\ttest2['_' + String.fromCharCode(i)] = i;\n\t\t}\n\t\tvar order2 = Object.getOwnPropertyNames(test2).map(function (n) {\n\t\t\treturn test2[n];\n\t\t});\n\t\tif (order2.join('') !== '0123456789') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// http://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test3 = {};\n\t\t'abcdefghijklmnopqrst'.split('').forEach(function (letter) {\n\t\t\ttest3[letter] = letter;\n\t\t});\n\t\tif (Object.keys(Object.assign({}, test3)).join('') !==\n\t\t\t\t'abcdefghijklmnopqrst') {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (err) {\n\t\t// We don't expect any of the above to throw, but better to be safe.\n\t\treturn false;\n\t}\n}\n\nmodule.exports = shouldUseNative() ? Object.assign : function (target, source) {\n\tvar from;\n\tvar to = toObject(target);\n\tvar symbols;\n\n\tfor (var s = 1; s < arguments.length; s++) {\n\t\tfrom = Object(arguments[s]);\n\n\t\tfor (var key in from) {\n\t\t\tif (hasOwnProperty.call(from, key)) {\n\t\t\t\tto[key] = from[key];\n\t\t\t}\n\t\t}\n\n\t\tif (getOwnPropertySymbols) {\n\t\t\tsymbols = getOwnPropertySymbols(from);\n\t\t\tfor (var i = 0; i < symbols.length; i++) {\n\t\t\t\tif (propIsEnumerable.call(from, symbols[i])) {\n\t\t\t\t\tto[symbols[i]] = from[symbols[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn to;\n};\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\tid: moduleId,\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","__webpack_require__.j = 633;","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t633: 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkIds[i]] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = self[\"webpackChunkvmc_website\"] = self[\"webpackChunkvmc_website\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [637], () => (__webpack_require__(8880)))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n"],"names":["deferred","___CSS_LOADER_EXPORT___","push","module","id","exports","cssWithMappingToString","list","toString","this","map","item","content","needLayer","concat","length","join","i","modules","media","dedupe","supports","layer","undefined","alreadyImportedModules","k","_k","cssMapping","btoa","base64","unescape","encodeURIComponent","JSON","stringify","data","sourceMapping","sourceURLs","sources","source","sourceRoot","getOwnPropertySymbols","Object","hasOwnProperty","prototype","propIsEnumerable","propertyIsEnumerable","toObject","val","TypeError","assign","test1","String","getOwnPropertyNames","test2","fromCharCode","n","test3","split","forEach","letter","keys","err","shouldUseNative","target","from","symbols","to","s","arguments","key","call","f","g","h","performance","now","l","unstable_now","p","Date","q","window","MessageChannel","t","u","w","a","b","setTimeout","clearTimeout","unstable_shouldYield","unstable_forceFrameRate","x","y","console","z","cancelAnimationFrame","requestAnimationFrame","error","A","B","C","D","E","Math","floor","F","G","port2","port1","onmessage","postMessage","H","c","d","e","I","J","K","pop","m","v","r","sortIndex","L","M","N","O","P","Q","R","S","T","callback","startTime","expirationTime","U","V","priorityLevel","W","unstable_IdlePriority","unstable_ImmediatePriority","unstable_LowPriority","unstable_NormalPriority","unstable_Profiling","unstable_UserBlockingPriority","unstable_cancelCallback","unstable_continueExecution","unstable_getCurrentPriorityLevel","unstable_getFirstCallbackNode","unstable_next","unstable_pauseExecution","unstable_requestPaint","unstable_runWithPriority","unstable_scheduleCallback","delay","unstable_wrapCallback","apply","stylesInDOM","getIndexByIdentifier","identifier","result","modulesToDom","options","idCountMap","identifiers","base","count","indexByIdentifier","obj","css","sourceMap","references","updater","addElementStyle","byIndex","splice","api","domAPI","update","newObj","remove","lastIdentifiers","newList","index","newLastIdentifiers","_i","_index","memo","insert","style","styleTarget","document","querySelector","HTMLIFrameElement","contentDocument","head","getTarget","Error","appendChild","element","createElement","setAttributes","attributes","styleElement","nonce","setAttribute","insertStyleElement","styleTagTransform","parentNode","removeChild","removeStyleElement","styleSheet","cssText","firstChild","createTextNode","className","BlogPost","title","url","imgUrl","postSummery","src","alt","href","root","rootMargin","threshold","blogPostBlockInfo","render","containerRef","useRef","isLoaded","setIsLoaded","useState","blogPosts","setBlogPosts","observeCallback","entries","observer","entry","isIntersecting","fetch","blogUrl","method","headers","then","response","text","xmlText","items","DOMParser","parseFromString","replace","querySelectorAll","posts","innerHTML","desc","imgMatch","match","imgLink","subText","trim","subTextTrunLength","min","substring","subTextElem","textContent","innerText","isFavored","categoryElem","includes","publishDateElem","publishDate","postLink","ex","log","sort","slice","disconnect","useEffect","current","IntersectionObserver","observe","ref","post","textAlign","fontSize","ctaUrl","ctaUrlTarget","ctaText","getElementById","blogDivId","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","chunkIds","fn","priority","notFulfilled","Infinity","fulfilled","j","every","getter","__esModule","definition","o","defineProperty","enumerable","get","prop","installedChunks","chunkId","webpackJsonpCallback","parentChunkLoadingFunction","moreModules","runtime","some","chunkLoadingGlobal","self","bind","__webpack_exports__"],"sourceRoot":""}